<template>
  <el-dialog title="患者报告" :visible="value" width="1000px" custom-class="dialog-box" @close="onClose" @open="onOpen" :close-on-click-modal="false" :append-to-body="true">
    <el-timeline>
      <el-timeline-item v-for="(obj,index) in reportList" :key="obj.cureId" :color="reportFlog==index?'#32BC95':''" :timestamp="obj.date" placement="top">
        <div @click="toggleReport(index)" class="look-report">查看报告
          <i class="el-icon-arrow-down"></i>
        </div>
        <el-card v-if="reportFlog==index">
          <reportRecord :cureId="obj.cureId" :patientId="patientId"></reportRecord>
        </el-card>
      </el-timeline-item>
    </el-timeline>
    <!--  -->
  </el-dialog>
</template>
<script>
export default {
  props: ["value", "cureId", "patientId"],
  components: {
    reportRecord: () => import("@/pages/_com/reportRecord.vue")
  },
  data() {
    return {
      show: false,
      reportList:[],
      reportFlog:-1
    };
  },
  methods: {
    onOpen() {
      this.getReportList();
    },
    onClose() {
      this.$emit("input", false);
      this.reportFlog=-1;
    },
    getReportList(){
      this.$api.getPatientReportDate({patientId:this.patientId}).then(res=>{
        if(res.executed){
           let list=res.dataBody;
           list.forEach(item => {
              item.show=false;
           });
           this.reportList=list;
        }
      })
    },
    toggleReport(num){
       this.reportFlog=num;
    }
  }
};
</script>
<style lang="scss" scoped>
  .look-report{
   color:#32BC95;
   margin-bottom: 10px;
   cursor: pointer;
  }
</style>>